package com.qingke.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

public class WordDAO {

	public String getWord(SqlSession session,String en) {
		//SqlSession session = WSessionFactory.getInstance().getSession();
		WordMapper mapper = session.getMapper(WordMapper.class);
		String cn = mapper.getWord(en);
		return cn;
	}
	
	public void insertWord(SqlSession session,String en,String cn) {
		//SqlSession session = WSessionFactory.getInstance().getSession();
		WordMapper mapper = session.getMapper(WordMapper.class);
		if(getWord(session,en) == null) {
			mapper.insertWord(en, cn);			
		}
	}
	
	public List<Map<String,String>> searchWord(SqlSession session,String en) {
		//SqlSession session = WSessionFactory.getInstance().getSession();
		WordMapper mapper = session.getMapper(WordMapper.class);
		List<Map<String,String>> list = mapper.searchWord(en);
		return list;
	}
}
